﻿using System.Collections.Generic;
using Microsoft.Practices.SharePoint.Common.Configuration;
using Microsoft.SharePoint.Administration;
using System.Linq;
using SharePoint.Contrib.App.Settings;

namespace SharePoint.Contrib.Extensions
{
    /// <summary>
    /// Extensions for the SPWebApplication class
    /// </summary>
    public static class SPWebApplicationExtensions
    {
        /// <summary>
        /// Retrieves the collection of settings for the SPWebApplication
        /// </summary>
        public static ISettingCollection Settings(this SPWebApplication instance)
        {
            IPropertyBag properties = instance.PropertiesBag();
            return new SPWebApplicationSettingCollection(properties, instance);
        }


        private static IPropertyBag PropertiesBag(this SPWebApplication instance)
        {
            IPropertyBag properties = new SPWebAppPropertyBag(instance);
            return properties;
        }
    }
}
